package pack1;
import java.io.*;
import java.net.InetAddress;
import java.net.Socket;
import java.util.Scanner;

/**
 * @author wenze-zero
 */
public class Client {
    public static void main(String[] args) throws IOException {
        Scanner in=new Scanner(System.in);
        Socket sk=new Socket(InetAddress.getByName("172.22.17.255"),10086);
        OutputStream os = sk.getOutputStream();
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        System.out.print("请输入账号");
        String account=br.readLine();
        System.out.print("请输入密码");
        String password=br.readLine();
        String cc=account+"/"+password;
        os.write(cc.getBytes());
        InputStream is= sk.getInputStream();
        byte[] bys=new byte[1024];
        int len=is.read(bys);
        String data=new String(bys,0,len);
        System.out.println("服务端反馈"+data);
        if (data.equals("accept")){
            int num;
            System.out.println("请求服务:");
            System.out.println("1表示请求文件传输服务");
            System.out.println("2表示请求数据库查询服务");
            num=in.nextInt();
            os.write(num);
            byte[] bt=new byte[1024];
            int le=is.read(bt);
            String da=new String(bt,0,le);
            System.out.println("服务端反馈"+da);
            os.write("finish".getBytes());
        }
    }
}
